package apof.info.rss
{
	public class RssParse20 implements IRssParse
	{	
		private var _rssInfo:RssInfo;
		private var content:Namespace  = new Namespace("http://purl.org/rss/1.0/modules/content/");

		
		public function Parss(rssXml:XML):RssInfo{
			var rssReader:XML = rssXml.channel[0];
			_rssInfo = new RssInfo();
			 _rssInfo.title = rssReader.title;
             _rssInfo.subTitle = rssReader.description;
             _rssInfo.url = rssReader.link;
              
              var updated:String = rssReader.lastBuildDate;
              var t:Date = new Date(Date.parse(updated));
               // var t:Date = tn as Date;
               // t.setMilliseconds(tn);
               
              _rssInfo.updateTime = t.fullYear.toString()+"/"+
                	  t.getMonth().toString()+"/"+
                	  t.getDate().toString()+" "+
                	  t.getHours().toString()+":"+
                	  t.getMinutes().toString()+":"+
                	  t.getSeconds().toString();
                	  
            //
            _rssInfo.rssItemArray = ParseRssItem(  rssXml );  	  
			return _rssInfo;
		}
		
		private function ParseRssItem(rssXml:XML):Array{
			var itemArray:Array = new Array();
			var itemList:XMLList = rssXml.channel[0].item;
			var item:XML;
			for each(item in itemList){
				var rssItem:RssItem = new RssItem();
				rssItem.title = item.title;
				rssItem.url = item.link;
				rssItem.author = item.author;
				rssItem.description = item["description"];
				rssItem.content = item.content::encoded;
				itemArray.push(rssItem);
			}
			
			return itemArray;
		}
		
		public function get rssInfo():RssInfo{
			return _rssInfo;
		}
	}
}